/*
 * @Description:  
 * @Author: YiHe
 * @Date: 2020-08-20 16:03:32
 * @LastEditors: YiHe
 * @LastEditTime: 2020-08-20 23:04:09
 */
import observe from './obsever.js'
import Compile from './compile.js'
import Watcher from './watcher.js'
class MVVM {
	constructor(options) {
		this.options = options
		Object.keys(this.options.data).forEach(key => {
			this._proxy(key)
		})
		observe(this.options.data)
		new Compile(options.el || document.body, this)
	}
	_proxy(key) {
		Object.defineProperty(this, key, {
			get: function proxyGetter() {
				return this.options.data[key]
			},
			set: function proxySetter(newVal) {
				this.options.data[key] = newVal
			}
		})
	}
}
export default MVVM